// Main javascript entry point
// Should handle bootstrapping/starting application


'use strict';

var $ = require('jquery');
//var Link = require('../_modules/link/link');
require('jquery.easing');



$(function(){
    //$('.nav li').eq(0).addClass("act");
    //$('.nav li').each(function(){
    //
    //})


});

$(function(){
    $(".nav li a").click(function(){
        var href = $(this).attr("href");
        var pos = $(href).offset().top;
        $("html,body").animate({scrollTop: pos}, 1000);

        //$(this).parent('li').addClass("act").end().parent('li').siblings().removeClass('act');

        return false;
    });
})

$(function(){
    //page.util.init();
    $(window).on({
        load : function(){

        },

        resize: function(){

        },

        scroll :function(){
            var height=$(document).scrollTop();

            var height_friendly=$('.friendly-link').offset().top;

            if(height>height_friendly){
                $('.menu').addClass('menu1');
            }else{
                $('.menu').removeClass('menu1');
            }


        }



    });
});






$(document).ready(function(){
    var speed=10;
    var marquee_drawing=document.getElementById("marquee1");
    var marquee_drawing_1=document.getElementById("marquee1_1");
    var marquee_drawing_2=document.getElementById("marquee1_2");

    marquee_drawing_2.innerHTML=marquee_drawing_1.innerHTML;

    function marquee()
    {
        if(marquee_drawing_2.offsetWidth-marquee_drawing.scrollLeft<=0)
        {
            marquee_drawing.scrollLeft-=marquee_drawing_1.offsetWidth;
        }
        else
        {
            marquee_drawing.scrollLeft++;
        }
    }

    var MyMar2=setInterval(marquee,speed);

    marquee_drawing.onmouseover=function() {
        clearInterval(MyMar2);
    };

    marquee_drawing.onmouseout=function() {
        MyMar2=setInterval(marquee,speed);
    };


});



$(function(){
    /* -----------------------------------------------------
     sp nav
     ----------------------------------------------------- */
    var $navMenuWrap = $('.navbar-header');
    var $navMenu = $('.header-menu');
    var $navOver = $('.navbar-collapse');
    $navMenuWrap.on('click', function() {
        if($navMenu.hasClass('step2')){
            navClose();
        } else {
            navOpen();
        }
    });

    $('.navbar-collapse li a').on('click', function() {
        if($navMenu.hasClass('step2')){
            navClose();
        } else {
            navOpen();
        }
    });

    function navOpen(){
        $navOver.fadeIn(600);
        console.log(131);
        $navMenu.addClass('step2');
        $navMenu.delay(150).queue(function() {
            $navMenu.removeClass('step1').addClass('step2').dequeue();
        });
    }

    function navClose(){
        $navOver.fadeOut(600);
        $navMenu.removeClass('step2').addClass('step1');
        $navMenu.delay(150).queue(function() {
            $navMenu.removeClass('step1').dequeue();
        });
    }


});
